package cn.iocoder.yudao.module.infra.dal.mysql.face;

import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.infra.dal.dataobject.face.FaceLogDO;
import org.apache.ibatis.annotations.Mapper;

import java.time.LocalDateTime;

/**
 * 人脸验证日志 Mapper
 *
 * @author 芋道源码
 */
@Mapper
public interface FaceLogMapper extends BaseMapperX<FaceLogDO> {

    /**
     * 分页查询人脸验证日志
     *
     * @param userId 用户ID
     * @param operationType 操作类型
     * @param success 是否成功
     * @param beginTime 开始时间
     * @param endTime 结束时间
     * @return 分页结果
     */
    default PageResult<FaceLogDO> selectPage(PageParam pageParam, Long userId, String operationType, Boolean success,
                                              LocalDateTime beginTime, LocalDateTime endTime) {
        return selectPage(pageParam, new LambdaQueryWrapperX<FaceLogDO>()
                .eqIfPresent(FaceLogDO::getUserId, userId)
                .eqIfPresent(FaceLogDO::getOperationType, operationType)
                .eqIfPresent(FaceLogDO::getSuccess, success)
                .betweenIfPresent(FaceLogDO::getCreateTime, beginTime, endTime)
                .orderByDesc(FaceLogDO::getCreateTime));
    }

}